package com.hhs.storage.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.hhs.storage.bean.InputParam;
import com.hhs.storage.bean.Result;
import com.hhs.storage.bean.User;
import com.hhs.storage.bean.YymCjdata;
import com.hhs.storage.dao.YymCjdataDao;
import com.hhs.storage.service.YymCjdataService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author yuanjun
 * @since 2020-08-14
 */
@Service
public class YymCjdataServiceImpl extends ServiceImpl<YymCjdataDao, YymCjdata> implements YymCjdataService {

    public Map<String, Object> saveOrUpdate(YymCjdata yymCjdata) {
        List<YymCjdata> tempList = this.baseMapper.selectList(new EntityWrapper<YymCjdata>().eq("map_id_", yymCjdata.getMapId()));
        if (tempList.size() > 0 ) {
            return Result.failJsonResp2(tempList.get(0));
        }
        this.insertOrUpdate(yymCjdata);

        return Result.sucJsonResp(yymCjdata);
    }

    @Override
    public Page<YymCjdata> findPage(Page<YymCjdata> page, InputParam inputParam) {// 当前页，总条数 构造 page 对象
        return page.setRecords(this.baseMapper.findPage(page,inputParam));
    }

}
